package com.meichis.yndms.adapter;

import android.content.Context;

import com.meichis.mcsappframework.adapter.recyclerview.CommonAdapter;
import com.meichis.mcsappframework.adapter.recyclerview.base.ViewHolder;
import com.meichis.mcsappframework.utils.ArithUtil;
import com.meichis.yndms.R;
import com.meichis.yndms.model.VstAnalyse;

import java.util.List;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-05-29 10:25
 */
public class VstAnalyseAdapter extends CommonAdapter<VstAnalyse> {


    public VstAnalyseAdapter(Context context, int layoutId, List<VstAnalyse> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, VstAnalyse vstAnalyse, int position) {
        holder.setText(R.id.tv_name, vstAnalyse.getUserName());
        holder.setText(R.id.tv_play, ArithUtil.roundStr(vstAnalyse.getJHBFTerminalNum(), 0));
        holder.setText(R.id.tv_cur, ArithUtil.roundStr(vstAnalyse.getDQBFTerminalNum(), 0));
        holder.setText(R.id.tv_client, String.valueOf(vstAnalyse.getXSTerminalNum()));
        holder.setText(R.id.tv_percent, ArithUtil.roundStr(vstAnalyse.getDQBFTerminalNum() * 100 / vstAnalyse.getJHBFTerminalNum(), 2) + "%");
        holder.setText(R.id.tv_tally_stores, String.valueOf(vstAnalyse.getLHTerminalNum()));
        holder.setText(R.id.tv_tally_rate, vstAnalyse.getLHRate());

        if (position % 2 == 0) {
            if (position == mDatas.size() - 1) {
                holder.setBackgroundRes(R.id.ll_item, R.drawable.shape_fillet_bottom_solid_white);
            } else {
                holder.setBackgroundRes(R.id.ll_item, R.color.white);
            }
        } else {
            if (position == mDatas.size() - 1) {
                holder.setBackgroundRes(R.id.ll_item, R.drawable.shape_fillet_bottom_solid_theme_light);
            } else {
                holder.setBackgroundRes(R.id.ll_item, R.color.theme_light);
            }
        }


    }
}
